	
	** Clean Wave 1
		
		** Household info
		
			use "$dir/rawdata/GSPS Ghana/Wave 1/key_hhld_info.dta", clear
			
				gen w1_urban=urbrur==1 if !missing(urbrur)
				
				keep FPrimary w1_urban
				tostring FPrimary, replace
				tempfile urban
				save `urban', replace
		
		** Roster
			/*use "$dir/rawdata/GSPS Ghana/Wave 3/01b2_roster.dta", clear
				gen w1_age=ageyears
				gen w1_female=gender==5 if !missing(gender) 
				gen w1_married=maritalstatus==1 if !missing(maritalstatus)
				gen w1_inhh=1*/
				
			use "$dir/rawdata/GSPS Ghana/Wave 1/s1d.dta", clear
				gen w1_age=s1d_4i
				gen w1_female=s1d_1==2 if !missing(s1d_1)
				gen w1_married=s1d_6==1 if !missing(s1d_6)
				gen w1_inhh=1
				
				tostring(FPrimary), replace
				
				bys FPrimary: gen w1_hh_size=_N
				
				keep FPrimary hhmid w1_*
				
				tempfile roster
				save `roster', replace
			
		** Employment: Non household business, non-agriculture
		
			use "$dir/rawdata/GSPS Ghana/Wave 1/s1ei.dta", clear
			
				gen w1_work_primary=s1ei_1==1 if !missing(s1ei_1)
				gen w1_work_primary_hrs=s1ei_8ii*s1ei_8i
				
				keep FPrimary hhmid w1_*
				
				tostring FPrimary, replace
				
				tempfile employment1
				save `employment1', replace
			
			use "$dir/rawdata/GSPS Ghana/Wave 1/s1eii.dta", clear
			
				gen w1_work_secondary=!missing(s1eii_31)
				gen w1_work_secondary_hrs=s1eii_36ii*s1eii_36iii		
				
				keep FPrimary hhmid w1_*
				
				tostring FPrimary, replace
				
				tempfile employment2
				save `employment2', replace
				
		** Employment: Household enterprise
			
			use "$dir/rawdata/GSPS Ghana/Wave 1/s5bii.dta", clear
			
				keep FPrimary entno s5bii_10aii-s5bii_15d
				ren s5bii_10*ii s5bii_10*
				ren *a *1
				ren *b *2
				ren *c *3
				ren *d *4
				reshape long s5bii_10 s5bii_11 s5bii_12 s5bii_13 s5bii_14 s5bii_15, i(FPrimary entno) j(worker)
				
				ren s5bii_10 hhmid
				
				gen last7_hrs=(s5bii_12*s5bii_13)/2 // divide by 2 weeks to get weekly
				gen usual_hrs=(s5bii_14*s5bii_15)/4 // divide by 4 weeks to get weekly
			
				gen w1_work_enterprise_hrs_temp=last7_hrs
				replace w1_work_enterprise_hrs_temp=usual_hrs if missing(last7_hrs)
				
				gen w1_work_enterprise_temp=w1_work_enterprise_hrs_temp>0 if !missing(w1_work_enterprise_hrs_temp)
				
				bys FPrimary hhmid: egen w1_work_enterprise_hrs=total(w1_work_enterprise_hrs_temp)
				bys FPrimary hhmid: egen w1_work_enterprise=max(w1_work_enterprise_temp)
				
				keep FPrimary hhmid  w1_work_enterprise_hrs w1_work_enterprise
				drop if missing(hhmid)
				drop if hhmid==-8
				duplicates drop
				isid FPrimary hhmid
				
				tostring FPrimary, replace
				
				tempfile enterprise
				save `enterprise', replace
								
		** Depression
			use "$dir/rawdata/GSPS Ghana/Wave 1/s10ai.dta", clear
	
			gen w1_age=s1d_4i
			gen w1_female=s1d_1==2 if !missing(s1d_1)
			
			replace s10ai_a3=1 if s10ai_a2==1
			replace s10ai_a6=1 if s10ai_a5==1
			
			egen w1_depression_score=rowtotal(s10ai_a1 s10ai_a2 s10ai_a3 s10ai_a4 s10ai_a5 s10ai_a6 s10ai_a7 s10ai_a8 s10ai_a9 s10ai_a10), mi
			egen w1_depression_nonmiss=rownonmiss(s10ai_a1 s10ai_a2 s10ai_a3 s10ai_a4 s10ai_a5 s10ai_a6 s10ai_a7 s10ai_a8 s10ai_a9 s10ai_a10)
			replace w1_depression_score=. if w1_depression_nonmiss<10 // FIXME: Check if this is the right way
			
				compare w1_depression_score depressed
				
				*ren depressed w1_depression_score
				*ren depression depression_orig
				*gen w1_depressed=(depression_orig==2 | depression_orig==3 | depression_orig==4) if !missing(depression_orig)
			
			gen w1_depressed=w1_depression_score>=25 if !missing(w1_depression_score) // moderate or severe
			*gen w1_depressed=w1_depression_score>=30 if !missing(w1_depression_score) // severe
			
			tostring FPrimary, replace
			
			keep FPrimary hhmid w1_*
			tempfile depression
			save `depression', replace
			
	** Ever covered by health insurance
		use "$dir/rawdata/GSPS Ghana/Wave 1/s6a.dta", clear
		gen w1_healthinsurance_ever=s6a_a1==1 if !missing(s6a_a1)
		keep FPrimary hhmid w1_healthinsurance_ever
		tostring FPrimary, replace
		tempfile healthinsurance
		save `healthinsurance', replace
		
	** Illness or injury over the past 2 weeks
		use "$dir/rawdata/GSPS Ghana/Wave 1/s6f.dta", clear
			gen w1_ill_inj=(s6f_1==2 | s6f_1==3) if !missing(s6f_1)
			gen w1_ill_inj_stopactivity=s6f_6==1 if !missing(s6f_6) // FIXME: This seems to be missing for a lot of observations where illness/injury=yes
			replace w1_ill_inj_stopactivity=0 if w1_ill_inj==0
			
		keep FPrimary hhmid w1_*
		tostring FPrimary, replace
		tempfile illnessinjury
		save `illnessinjury', replace
			
		** Merge 
			use `roster', clear
			merge 1:1 FPrimary hhmid using `employment1', gen(merge_employment1)
			merge 1:1 FPrimary hhmid using `employment2', gen(merge_employment2)
			merge 1:1 FPrimary hhmid using `enterprise', gen(merge_enterprise)
			merge 1:1 FPrimary hhmid using `depression', gen(merge_depression)
			merge 1:1 FPrimary hhmid using `healthinsurance', gen(merge_healthinsurance)
			merge 1:1 FPrimary hhmid using `illnessinjury', gen(merge_illinj)
			merge m:1 FPrimary using `urban', gen(merge_urban)
			
			ren FPrimary hhid
			ren hhmid indiv
			
			order hhid indiv w1_*
			keep hhid indiv w1_*
			
			destring hhid, replace
			
			save "$dir/data/gha_w1_individual.dta", replace
		
	
	** Variables to create
	
		** In household
			** Age
			** Gender
			** Urban status
			
		** Works any
		** Work hours
		** Lives alone
		
			** Married
			** Illness or injury
			** Stopped activities due to illness or injury
			** Depression
			
	** Source for Kessler depression stuff

		* https://www.worksafe.qld.gov.au/__data/assets/pdf_file/0010/22240/kessler-psychological-distress-scale-k101.pdf
		